<template>
  <div>
    <el-container>
      <el-aside width="auto">
        <home-aside :isShrink="!isShrink"></home-aside>
      </el-aside>
      <el-container>
        <el-header>
          <home-header :isShrink="isShrink" @Shrink="isShrinkHandle">
          </home-header>
        </el-header>
        <el-main>
          <transition name="fadeChange" appear mode="out-in">
            <router-view></router-view>
          </transition>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import HomeAside from '@/components/HomeAside.vue'
import HomeHeader from '@/components/HomeHeader.vue'
export default {
  components: { HomeAside, HomeHeader },
  data () {
    return {
      // 侧边栏的显示和隐藏状态
      isShrink: ((sessionStorage.getItem('isShrink')) === 'true')
    }
  },
  watch: {
    isShrink (value) {
      sessionStorage.setItem('isShrink', value)
    }
  },
  methods: {
    // 侧边栏的显示和隐藏状态方法
    isShrinkHandle () {
      this.isShrink = !this.isShrink
    }
  }
}
</script>
<style lang='scss'>
.el-header {
  line-height: 60px;
  border-bottom: 2px solid #ddd;
}
.el-aside {
  position: sticky;
  top: 0;
  left: 0;
  background-color: #222;
  text-align: center;
  height: 100vh;
}
.el-menu {
  border: 0;
}
body > .el-container {
  margin-bottom: 40px;
}
</style>
